#include "clienthandler.h"

ClientHandler::ClientHandler(QTcpSocket *client,QObject *parent) : QObject(parent),mSocket(client)
{
    connect(client,SIGNAL(readyRead()),this,SLOT(onReadMessage()));
    client->write("hi");
}

void ClientHandler::write(const QByteArray &array)
{
    mSocket->write(array);
}

void ClientHandler::onReadMessage()
{
    while(mSocket->canReadLine())
        {
            QByteArray array=mSocket->readLine();
            emit  received(array,mSocket);
        }
}

